The Kinetis SDK provides both HAL and Peripheral drivers for the Microseconds Timer (MSTIMER) block of Kinetis devices, which is based on the PIT driver.
More...
Overview
Microseconds driver provides an easy way to delay specific time or to measure running time of one segment code. The timer will run endlessly before microseconds_shutdown being called. Since the timer is 64 bits, the counter will never reach to 0 in centuries.NOTE: using microseconds driver will change pit settings, so avoid using this if pit is used for other purpose.
Initialization
To initialize the pit module, simply call
microseconds_init(). This will chain pit timer 0 and timer 1 together as a 64 bit lifetime timer, and set period of both timer 0 and timer 1 to maximum value.
Microseconds Delay
Simply call microseconds_delay with passing in the delay time in unit of microseconds. It performs as busy waiting and could be affected by interrupts.Example code to use microseconds delay:
Microseconds Get
Microseconds_get function can be used to measure running time of one segment of code. Call microseconds_get at the beginning of target code segment, call microseconds_get at the end of segment. The running time in microseconds unit could be get by subtracting end time from start time.Example code to use microseconds get:
runningTime = startTime - endTime;